<?php
include '../c/config.php';
$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqli->error);}

 
$query=$mysqli->query("SELECT dan FROM `ti` where step=1    ");
$yiDan=array();
$i=1;
while ($list=$query->fetch_array()) {
    $yiDan[$i]=$list['dan'];

$i++;
}
//var_dump($yiDan);
echo "<br /><br />";
 
$table='d6';
$query=$mysqli->query("SELECT yi,id FROM `".$table."` WHERE `fen` IS NULL limit 0,1 ");
while ($list=$query->fetch_assoc()) {
   $userYi=json_decode($list['yi'], true);
   $userDui=0;
   foreach ($userYi as $key => $value) {
       if ($value == $yiDan[$key]) {
           $userDui++;
           echo $key,"...",$value,'.....',$yiDan[$key];
           echo "<br />";
       }
   }

  echo $userDui;
  echo "<br /><br />";
   var_dump($userYi);
 echo "<br /><br />";
 
 $sql="update `".$table."` set fen=".$userDui." WHERE id='".$list['id']."'";
 $mysqli->query($sql);
    echo $sql;

}

?>
<script type="text/javascript">
    window.setTimeout(function(){
         window.location.reload();
    }, 300);

</script>
 
 